#include <stdio.h>
#include "msg_queue_peer.h"
union data
{
    int a;
    float val;
};
struct stm32_data
{
    long a;
    int key;
    int type;
    union data val;
};
struct modbus_data
{
    long a;
    int type;
    int addr;
    int key;
    union data val;
};
struct stm32_data stm32data;
struct modbus_data modbusdata;
int main(int argc, char const *argv[])
{
    long stm23type = 1;
    long modbustype = 2;
    while (1)
    {
        msg_queue_recv("send_write_que.c", &modbusdata, sizeof(modbusdata), modbustype, 0);
        if (modbusdata.type==1)
        {
            printf("key:%d addr:%d  val:%d\n", modbusdata.key,modbusdata.addr, modbusdata.val.a);
        }
        else if(modbusdata.type==3)
        {
            printf("key:%d addr:%d  val:%.2f\n", modbusdata.key,modbusdata.addr, modbusdata.val.val);
        }
        // msg_queue_recv("send_write_que.c", &stm32data, sizeof(stm32data), stm23type, 0);
        // if (stm32data.type == 3)
        // {
        //     printf("%d  %.2f\n", stm32data.key,stm32data.val.val);
        // }
        // else
        // {
        //     printf("%d  %d\n", stm32data.key, stm32data.val.a);
        // }

        sleep(1);
    }

    return 0;
}